<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>样式绑定语法</title>
    <style>
        .blue{
            color: blue;
        }

        .green{
            color: green;
        }

        .purple{
            color: purple;
        }
    </style>
  </head>
  <body>
    <script src="https://unpkg.com/vue@next"></script>

    <div id="root"></div>

    <script>
      const app = Vue.createApp({
        data() {
          return {
              classString:"blue",
              classObject:{blue:false, purple:true},
              classArray:["blue","green",{purple:true}],

              styleString:"color:red; font-size:30px;",
              styleObject:{
                  color:"yellow",
                  fontWeight:"bold"
              }
          };
        },

        //template: `<div :class="classArray">hello world</div>`,
        template: `<div :style="styleObject">
                        hello world
                        <demo class="blue"/>
                    </div>`,
      });


      app.component("demo", {

        //  template:`<div class="purple">one demo</div>
        //            <div  class="purple">two demo</div>
        //   `
          template:`
                    <div :class="$attrs.class">one demo</div>
                    <div>two demo</div>
           `
      })


   

      const vm = app.mount("#root");
    </script>
  </body>
</html>
